# -*- coding: utf-8 -*-

#!/usr/bin/python
import smtplib
from email.mime.text import MIMEText


def sendMail(user, pwd, to, subject, text):
    msg = MIMEText(text)
    msg['From'] = user
    msg['To'] = to
    msg['Subject'] = subject
    
    try:
        smtpServer = smtplib.SMTP('mail.163.com', 25)
        print "[+] Connecting To Mail Server."
        smtpServer.set_debuglevel(1)
        smtpServer.ehlo()
        print "[+] Starting Encrypted Session."
        # smtpServer.starttls()
        smtpServer.ehlo()
        print "[+] Logging Into Mail Server."
        smtpServer.login(user, pwd)
        print "[+] Sending Mail."
        smtpServer.sendmail(user, to, msg.as_string())
        smtpServer.close()
        print "[+] Mail Sent Successfully."
    except:
        print "[-] Sending Mail Failed."


<<<<<<< HEAD
user = 'testaaa@21tb.com'
pwd = 'xxxxxxxx'

sendMail(user, pwd, 'testbbb@21tb.com',
=======
user = 'test@163.com'
pwd = 'xxxxxxxx'

sendMail(user, pwd, 'test@163.com',
>>>>>>> 2bf0cb1ed38f1c08f96b9b5f3d9ca8673ef9905b
         'hello', 'hello')

